/**
 * @file Triangle.cpp
 * 
 * This file contains the definitions of all the funcitons to manipulate the 
 * Triangle class.
 */
#include "Shape.hpp"
#include "Triangle.hpp"
#include <cmath>

/**
 * Default constructor
 */
Triangle::Triangle(){}

/**
 * Triangle constructor
 * @param name: x, y, size, and color - description: center point, size and color
 * given by the user.
 */
Triangle::Triangle( int x, int y, int size, COLORREF color ) : Shape( x, y, size, color )
{}

/**
 * Destructor
 */
Triangle::~Triangle(){}

/**
 * Returns true if coordinance of a point is inside the Triangle
 * @param name: x, y - description: coordinance given by the user.
 */
bool Triangle::contains( int x, int y )
{
	int X, Y;

	X = x - a.x;
	Y = y - a.y;

	if (abs (X * 2) < Y && y < b.y )
		return true;
	else
		return false;
}

/**
 * Draws a circle inside the shape boundaries.
 * @param name: canvas - description: object passed by reference to 
 * specify how a circle should be drawn.
 */
void Triangle::draw( Canvas& canvas )
{
	setPoints();
	canvas.drawTriangle( a, b, c, RGB( 0,0,0 ), color );
}

/**
 * Sets the three points of a Triangle
 */
void Triangle::setPoints()
{
	a.x = x;
	a.y = y - size / 2;
	b.x = x - size / 2;
	b.y = y + size / 2;
	c.x = x + size / 2;
	c.y = y + size / 2;
}

